package com.itheima.ydd.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.ydd.dto.CateInfo;
import com.itheima.ydd.entity.Cate;
import org.apache.ibatis.annotations.*;

import java.util.HashMap;
import java.util.List;

/**
 * Mapper接口
 */
@Mapper
public interface CateMapper extends BaseMapper<Cate> {
    @Select("SELECT  catename,count AS num,cateid AS id FROM \n" +
            "(select A.sort_num AS sort,A.catename ,B.count,B.cateid from ydd_cate A\n" +
            " inner join (select cateid,count(cateid) as count from ydd_article group by cateid)B ON A.id=B.cateid)C \n" +
            " ORDER BY sort")
    List<CateInfo> getAllCate();
}
